package com.hmdp.controller;

import com.hmdp.dto.Result;
import com.hmdp.entity.ShopRates;
import com.hmdp.service.ShopRatesService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/shopRates")
public class ShopRatesController {
    @Resource
    private ShopRatesService shopService;

    @PostMapping("/saveRates")
    public Result saveRates(@RequestBody ShopRates shopRates){

        return shopService.saveRates(shopRates);
    }

    @GetMapping("/queryRates/{shopId}")
    public Result queryRates(@PathVariable("shopId") Long shopId){
        ShopRates shop = shopService.query().eq("shop_id", shopId).one();
        return Result.ok(shop);
    }
}
